/**
 * This program is free software but WITHOUT ANY WARRANTY OR CONDITIONS OF ANY KIND.
 *
 * Copyright (C) 2008 www.pretty-tools.com
 */

/**
 * Manages dialog and other windows of web slide show
 */
var wsshWindowManager = {};

wsshWindowManager.getManager = function()
{
    if (!this.manager)
        this.manager = yrprxComponentsFactory.createWindowManager();

    return this.manager;
}

wsshWindowManager.openSlideShow = function(images, title, workWindow)
{
    if (!title)
        title = window.document.title;

    this.getManager().openFullScreen("res://{8706081B-A7C0-4EC6-BDFF-A6F54B24A837}/SLIDESHOW.HTM", images, title, workWindow);
}

wsshWindowManager.openSaveImagesProgressDialog = function(sources, destFolder)
{
    this.getManager().openDialog("res://{8706081B-A7C0-4EC6-BDFF-A6F54B24A837}/SAVEIMAGESPROGRESSDIALOG.HTM", 500, 110, sources, destFolder);
}

wsshWindowManager.openOptionsModeless = function()
{
    this.getManager().openDialog("res://{8706081B-A7C0-4EC6-BDFF-A6F54B24A837}/OPTIONS.HTM", 800, 500);
}

wsshWindowManager.openOptions = function()
{
    var url = this.getManager().resolveURL("res://{8706081B-A7C0-4EC6-BDFF-A6F54B24A837}/OPTIONS.HTM");
    window.showModalDialog(url, [], "dialogWidth=800px;dialogHeight=500px;status=no;center=yes;resizable=yes;");
}

wsshWindowManager.openRule = function(param)
{
    var url = this.getManager().resolveURL("res://{8706081B-A7C0-4EC6-BDFF-A6F54B24A837}/RULE.HTM");

    var params = [param];

    if (window.event.type == "keydown")
        params.push({keyCode: window.event.keyCode, shiftKey: window.event.shiftKey || window.event.shiftLeft, ctrlKey : window.event.ctrlKey, altKey: window.event.altKey});

    window.showModalDialog(url, params, "dialogWidth=700px;dialogHeight=250px;status=no;center=yes;resizable=no;help=no;");
}

wsshWindowManager.newXMLHttpRequest = function()
{
    return this.getManager().XMLHttpRequest;
}
